package com.zhht.checkcop.demo;

import java.util.List;
import java.util.Map;
import java.util.Random;

import com.zhht.checkcop.db.MysqlDb;
import com.zhht.checkcop.db.StaticDBMap;
import com.zhht.checkcop.util.HtmlRegexpUtil;


/**
 * 掌阅公版书籍爬取
 * http://m.zhangyue.com/category/92/126?currentPage=215
 * @author love
 *
 */
public class ZhangYuePublicChapterDataClean {
	
	 public static void main(String[] args) {
    	try{
    		List<Map<String, Object>> list=null;
        	
    		StaticDBMap.mysqldb = new MysqlDb();
    		StaticDBMap.mysqldb.connect();
//        	list = StaticDBMap.mysqldb.query("select bookId,name,author,zyId,chapternum from t_zy_book where bookId > 1904 limit 0,800");
        	list = StaticDBMap.mysqldb.query("select `id`,`content` from t_zy_chapter where id > 487 limit 0,10");
        	for(Map<String, Object> mm:list){
        		String id = mm.get("id")+"";
        		String content = mm.get("content")+"";
//        		content = content.replace("<br/>", "\r\n");
        		content = HtmlRegexpUtil.filterHtml(content).replace("\n    \n", "\n").replace("\n   \n", "\n");
//        		System.out.println(content);
        		StaticDBMap.mysqldb.execDB("UPDATE t_zy_chapter set newContent = '"+content+"' where id = "+ id);
        	}
    	}catch(Exception e){
    		
    	}
	 }
	    	
}	
